import sys
sys.path.append('../')

from testenv import *
from hdc import Hdc
import logging
import time

LITERATIONS = -1
INTERVAL = 2.0

hdc = Hdc()
cpu_count = hdc.cpu_count("")

def test():
    iteration = 0
    while(LITERATIONS == -1 or iteration < LITERATIONS):
        temperature = hdc.temperature("")
        logging.info(f"[Iteration {iteration}] | Temperature: {temperature}")
        time.sleep(0.1)
        for cpu_id in range(cpu_count):
            # only surpport root device
            freqs = hdc.get_cpu_frequency("", cpu_id)
            logging.info(f"[Iteration {iteration + 1}] | CPU {cpu_id}: {freqs["cpuinfo_cur_freq"]}")
            time.sleep(0.1)
        time.sleep(INTERVAL)
        if LITERATIONS > 0:
            iteration += 1

if __name__ == "__main__":
    test()